Skip to content

Conversation

@elianiva
Copy link
Contributor

@elianiva elianiva commented May 12, 2025

Caution

CAUTION, DISCLAIMER, READ THIS

If you test this PR, you will lose your taskHistory from the global state because it gets moved to an external file. Please be aware before testing this branch.

Related GitHub Issue

Not directly closes, but still related to the issue we've been having. See: #2391
This should address one of the causes

Description

Move task history out of globalState and use an external taskHistory.jsonl to store the history. This way it can grow to whatever it needs to be without polluting the globalState option.

I've added a mechanism to make the API reads from a file, so the code change should be minimal. I only need to update ContextProxy.ts to do file operations specifically for the taskHistory key.

Test Procedure

Upon opening vscode, you should see a little notification showing the task history has been migrated.

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

image

Other than this there's no screenshot as this is just moving where we store the history

Documentation Updates

Should we document this change? Like, telling where we store the history? I don't know

Additional Notes

Tests needed, still working on that


Important

Refactor task history management by moving it from global state to an external taskHistory.jsonl file, updating ContextProxy.ts and related tests.

  • Behavior:
    • Task history moved from global state to taskHistory.jsonl file in ContextProxy.ts.
    • readTaskHistoryFile() and writeTaskHistoryFile() handle file operations for task history.
    • On initialization, task history is migrated from global state to file if present.
  • Testing:
    • Updated tests in ContextProxy.test.ts to verify task history file operations.
    • Mock setup in vscode.js updated to simulate file operations for task history.
  • Misc:
    • Removed taskHistory from PASS_THROUGH_STATE_KEYS in ContextProxy.ts.

This description was created by Ellipsis for b9dabdb. You can customize this summary. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented May 12, 2025

⚠️ No Changeset found

Latest commit: 0609a29

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@elianiva elianiva marked this pull request as ready for review May 12, 2025 11:47
@elianiva elianiva requested review from cte and mrubens as code owners May 12, 2025 11:47
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels May 12, 2025
async updateGlobalState<K extends GlobalStateKey>(key: K, value: GlobalState[K]) {
if (key === "taskHistory") {
this.stateCache[key] = value
if (Array.isArray(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In updateGlobalState, the new branch for taskHistory only proceeds if the value is an array. It would be helpful to add a type check (or log a warning) if a non-array is passed, to help catch unexpected types.

This comment was generated because it violated a code review rule: mrule_OR1S8PRRHcvbdFib.

all: [],
},
},
FileSystemError: class {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a code property to the FileSystemError mock so that error.code comparisons in ContextProxy.ts work as expected.

This comment was generated because it violated a code review rule: mrule_oAUXVfj5l9XxF01R.

await proxy.initialize()

// Directly modify the private stateCache property to clear any task history
;(proxy as any).stateCache.taskHistory = undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Directly modifying the private stateCache in tests (using ts-ignore) can be brittle. Consider exposing a test helper or method to reset state without bypassing encapsulation.

This comment was generated because it violated a code review rule: mrule_htmKIslKUiIk1Afo.

@hannesrudolph
Copy link
Collaborator

@elianiva you linked to a group of tasks. Does this fix all of those?

@cte
Copy link
Collaborator

cte commented May 12, 2025

What do you think about having a separate task history manager that handles all task history interactions (similar to the provider settings and custom modes managers), and we can remove it entirely from the ContextProxy?

If we go that route we might also want to create a base class for our various persistence-related managers (I can help with that).

@elianiva
Copy link
Contributor Author

@elianiva you linked to a group of tasks. Does this fix all of those?

not all of them, only the ones related with the massive global state
i couldn't find all the related issues so i just linked the umbrella issue and said it partially resolved them

just to notify that there is a fix for some of them and people can confirm if it works or not

What do you think about having a separate task history manager that handles all task history interactions (similar to the provider settings and custom modes managers), and we can remove it entirely from the ContextProxy?

you know what, that's actually a better idea. bunching them all together is a bit of a pain to test and not really good to read

want me to do it on another PR or is it fine if i just push more stuff on this one?

@hannesrudolph
Copy link
Collaborator

@elianiva i will back this one off to draft and then you can push more stuff to this one.

@hannesrudolph hannesrudolph marked this pull request as draft May 14, 2025 00:29
@hannesrudolph hannesrudolph moved this from New to PR [Greenlit] in Roo Code Roadmap May 14, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft/WIP] to PR [Pre Approval Review] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Greenlit] in Roo Code Roadmap May 20, 2025
@elianiva
Copy link
Contributor Author

superseded by #3785

@elianiva elianiva closed this May 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Greenlit] to Done in Roo Code Roadmap May 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Greenlit] to Done in Roo Code Roadmap May 22, 2025
@elianiva elianiva deleted the refactor/task-history-storage branch June 4, 2025 16:29
@elianiva elianiva restored the refactor/task-history-storage branch October 6, 2025 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants